'use strict';
const bcrypt = require('bcryptjs');

module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Class = app.model.define(
    'class',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
        class_name: STRING(32),
      school_id: INTEGER(11),
    },
    {
      tableName: 'class',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );

    Class.associate = () => {
    const { School } = app.model;
        Class.hasOne(School, {foreignKey: 'id', sourceKey: 'school_id'})
    };

  return Class;
};
